home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -serious- / programming / basic / mildred / mildred.lha / lha / HStarDemo.lha / starfield.asc < prev    next >
Text File  |  1999-03-08  |  4KB  |  132 lines

  1.  
  2. ;Horizontal Starfield with SineWave Logo
  3. ;
  4. ;Programmed by : Bruce Henderson (BaH)  07.03.1999
  5.  
  6. ; Includes segments of code by
  7. ; Mikkel Loekke, aka. FlameDuck,
  8. ; (explosion & sine demo)
  9. ; and Paul West (for Particle changes in Explosion demo)
  10.  
  11. ; Runs at 25fps on 060/50
  12.  
  13. WBStartup
  14. NoCli
  15.  
  16.  
  17. NEWTYPE .point
  18.   x.w
  19.   y.w
  20. End NEWTYPE
  21. NEWTYPE .point2
  22.   xspeed.w
  23.   yspeed.w
  24. End NEWTYPE
  25.  
  26. #numpnts=255                        ; Points set for each horizontal line.
  27. degrad.q = Pi/180                   ; Degree/Radian Converter
  28.  
  29. Dim pnt.point (#numpnts)
  30. Dim pnt2.point2 (#numpnts)
  31.  
  32. Dim Lookup(460)                      ; Setup our sine lookup table.
  33. For i=0 To 460
  34.   Lookup(i)=Sin((i)*degrad*2)*20
  35. Next
  36.  
  37. DEFTYPE.l
  38.  
  39. MCPU Processor                      ; Tell Mildred which CPU it should use.
  40. Mc2pCPUmode Processor               ; Tell Mildred which CPU it should use for c2p.
  41.  
  42. MReserveBitmaps 2                   ; Tell Mildred that we're going to use 3 chunky bitmaps.
  43. MReservec2pWindows 1                ; Tell it we only need one c2p display.
  44.  
  45. InitBank 0,320*256,$10000
  46. CludgeBitMap 2,320,256,8,Bank(0)
  47. LoadBitMap 2,"Logo.IFF"
  48. MBitmap 1,320,256                   ; This will contain our chunky buffer.
  49.  
  50. MPlanar16ToBitmap 1,Bank(0),320,256,320,256
  51.  
  52.  
  53.  
  54. .initgraphics
  55. MBitmap 0,320,256                   ; This will contain our chunky buffer.
  56.  
  57. Mc2pWindow 0,320,256                ; Setup structures for c2p conversions.
  58.  
  59. Dim bm.l(1)                         ; We use two bitmaps for double buffering
  60.  
  61. For l=0 To 1
  62.   ; Get some free CHIP memory
  63.   bm(l)=AllocMem(320*256,$10002)
  64.   If bm(l)   ; and if we succeed
  65.     ; make it a planar bitmap.
  66.     CludgeBitMap l,320,256,8,bm(l)
  67.   Else
  68.     End
  69.   EndIf
  70. Next l
  71.  
  72. Dim scrtaglst.TagItem(7)            ; All this stuff sets up our
  73. scrtaglst(0)\ti_Tag = #SA_Left      ; Taglist for the screen we
  74. scrtaglst(0)\ti_Data = 0            ; want.
  75. scrtaglst(1)\ti_Tag = #SA_Depth
  76. scrtaglst(1)\ti_Data = 8
  77. scrtaglst(2)\ti_Tag = #SA_Width
  78. scrtaglst(2)\ti_Data = 320
  79. scrtaglst(3)\ti_Tag = #SA_Height
  80. scrtaglst(3)\ti_Data = 256
  81. scrtaglst(4)\ti_Tag = #SA_BitMap
  82. scrtaglst(4)\ti_Data = Addr BitMap (0)
  83. scrtaglst(5)\ti_Tag = #SA_ShowTitle
  84. scrtaglst(5)\ti_Data = 0
  85. scrtaglst(6)\ti_Tag = #SA_Draggable
  86. scrtaglst(6)\ti_Data = 0
  87. scrtaglst(7)\ti_Tag = #TAG_END      ; The most important tag of them all.
  88.  
  89. ScreenTags 0,"MildredDEMO",&scrtaglst(0) ; Open our intuition screen.
  90.  
  91. DecodePalette 0,?incpal             ; Get our IncBin'ed palette info.
  92. ShowPalette 0                       ; Attach our palette to the screen.
  93.  
  94.  
  95. MParticleFormat 0
  96.  
  97. For t.l=0To #numpnts                ; Set up the starfield
  98.   pnt(t)\x=Rnd(319)+1
  99.   pnt(t)\y=t
  100.   pnt2(t)\xspeed=(Rnd(5)+1)*-1      ; Some random Speeds. (Remove *-1 to reverse)
  101.   pnt2(t)\yspeed=0
  102. Next
  103.  
  104. pge=0
  105.  
  106. Repeat                              ; Repeat our mainloop ....
  107.   deg+4
  108.   If deg>358
  109.     deg=0
  110.   EndIf
  111.  
  112.   Mc2p bm(pge)                      ; Double Buffer
  113.   ShowBitMap pge
  114.   WaitTOF_                          ; Smooooooth...
  115.   pge=1-pge
  116.   MCls
  117.  
  118.   MAddToParticles &pnt(0)\x,#numpnts,&pnt2(0)\xspeed    ; Move the Stars
  119.   MWrapParticles &pnt(0)\x,#numpnts                     ; If a Star falls off the end, put it back on the other side;
  120.   MPlotParticles &pnt(0)\x,#numpnts,255                 ; Draw them.
  121.  
  122.   For y=0 To 99 Step 2                            ; Do the sine wavey bits.
  123.     MScroll 0,y,100,2,100+Lookup(deg+y),70+y,1    ; Offset each line of our Logo with the Sinewave
  124.   Next
  125.  
  126. Until RawStatus($45)  ; .... Until we press Escape
  127. End                                 ; End of program.
  128.  
  129. Even                                ; put following data on an even address. Minor speed increase.
  130. .incpal
  131. IncBin "Logo.PAL" ; Include our palette information in the binary.
  132.